/**
 * @class   wosh::gui::WidgetNotification
 * @brief   Graphical interface of wosh::Notification
 *          
 *          
 *
 ****************************************************************************
 * @version $Id: WidgetNotification.h 2184 2010-03-20 13:19:23Z alex $
 * @author  Alessandro Polo
 ****************************************************************************/
/* Copyright (c) 2007-2010, WOSH - Wide Open Smart Home 
 * by Alessandro Polo - OpenSmartHome.com
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the OpenSmartHome.com WOSH nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY Alessandro Polo ''AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL Alessandro Polo BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ****************************************************************************/

#ifndef __WOSH_Gui_WidgetNotification_H__
 #define __WOSH_Gui_WidgetNotification_H__

 #include <core/Notification.h>

 #include <QtGui/QWidget>
 #include "ui_WidgetNotification.h"


namespace wosh {
 namespace gui {


class WidgetNotification : public QWidget {

    Q_OBJECT

	public:
		WidgetNotification(QWidget *parent = 0) : QWidget(parent)
		 {
			this->m_ui = new Ui::WidgetNotification();
			this->m_ui->setupUi(this);
		 }

		virtual ~WidgetNotification()
		 {
			delete this->m_ui;
		 }

	public slots:


		void loadNotification( const Notification* notif )
		 {
			if ( notif == NULL ) {
				this->m_ui->cmbPriority->setCurrentIndex(0);
				this->m_ui->txtPreferredCommunicator->setText("");

				this->m_ui->txtSenderUser->setText("");
				this->m_ui->txtSenderID->setText("");

				this->m_ui->txtRecipentUser->setText("");
				this->m_ui->txtRecipentID->setText("");
				this->m_ui->txtRecipentGroup->setText("");

				this->m_ui->chkReadTS->setChecked(false);
				this->m_ui->chkSentTS->setChecked(false);
				this->m_ui->txtReadTS->setText("");
				this->m_ui->txtSentTS->setText("");

				return;
			 }


		}

	

		bool saveNotification( Notification* notif )
		 {
			if ( notif == NULL ) return false;

			notif->setPriority( (Notification::PRIORITY)this->m_ui->cmbPriority->currentIndex()  );

			notif->setSender_User( this->m_ui->txtSenderUser->text().toLatin1().data() );
			notif->setSender_ID( this->m_ui->txtSenderID->text().toLatin1().data() );

			notif->setRecipent_User( this->m_ui->txtRecipentUser->text().toLatin1().data() );
			notif->setRecipent_ID( this->m_ui->txtRecipentID->text().toLatin1().data() );
			notif->setRecipent_Group( this->m_ui->txtRecipentGroup->text().toLatin1().data() );

			notif->setRead(	this->m_ui->chkReadTS->isChecked() );
			notif->setSent(	this->m_ui->chkSentTS->isChecked() );

			return true;
		 }

	protected:
		void changeEvent(QEvent *e) {
			QWidget::changeEvent(e);
			switch (e->type()) {
				case QEvent::LanguageChange:
					this->m_ui->retranslateUi(this);
					break;
				default:
					break;
			 }
		 }


	private:
		Ui::WidgetNotification *m_ui;


}; // class def

 }; // namespace gui
}; // namespace wosh


#endif //__WOSH_Gui_WidgetNotification_H__
